/*
 * @Author: wangc
 * @Date: 2020-08-09 19:02:42
 * @LastEditTime: 2020-08-22 11:51:01
 * @Description: 
 */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token:localStorage.getItem('token')?localStorage.getItem("token"):"",
    username:"",
  },
  getters: {
    
  },
  mutations: {
    changeToken(state,token){
      state.token = token;
      localStorage.setItem('token',token);
    },
    changeUserName(state,name){
      state.username = name;
      localStorage.setItem('username',name);
    }
  },
  actions: {
    changeToken(context,token){
      context.commit("changeToken",token);
    },
    changeUserName(context,name){
      context.commit("changeUserName",name);
    }
  }
})